﻿using System;
using Core.AbstractEntities;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Stack.Entities;
using Exceptions.Custom;
namespace Test
{
    /// <summary>
    /// Summary description for UnitTest_CustomException
    /// </summary>
    [TestClass]
    public class UnitTest_CustomException
    {
        /// <summary>
        /// Test if the system send a correct "Exception"
        /// </summary>
        [ExpectedException(typeof(DivideByZeroException), "/ Error: Infinite Result")]
        [TestMethod]
        public void TestException_DividedByZeroExceptionExpected()
        {
            HpPile hpile = new HpPile();
            InitialiseForTesthpile(hpile);

            hpile.AddElement(new HpElement() {  Value = 0 });
            hpile.AddElement(new HpElement() {  Value = 50 });
            //Add the '/' operator
            hpile.AddElement(new HpElement() {  Value = '/' });
         
        }


        /// <summary>
        /// Test if the system send a correct "Exception".
        /// </summary>
        [ExpectedException(typeof(HpException), "/ Error: Too Few Arguments")]
        [TestMethod]
        public void TestException_InvalidOperationException()
        {
            HpPile hpile = new HpPile();

            //Add the '/' operator
            hpile.AddElement(new HpElement() { Value = '/' });

        }

        private static void InitialiseForTesthpile(HpPile hpile)
        {
            HpElement element1 = new HpElement();
            element1.Value = 1;

            HpElement element2 = new HpElement();
            element2.Value = "this is a string";

            HpElement element3 = new HpElement();
            element3.Value = 'c';

            HpElement element4 = new HpElement();
            element4.Value = 3.141516;

            //Add element integer
            hpile.AddElement(element1);
            //Add element string
            hpile.AddElement(element2);
            ////Add element character
            hpile.AddElement(element3);
            ////Add element double
            hpile.AddElement(element4);
        }
    }
}
